package com.dede.loadsirtest

import android.os.Bundle
import android.os.Handler
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.dede.loadsirtest.callBack.EmptyCallback
import com.dede.loadsirtest.callBack.ErrorCallback
import com.dede.loadsirtest.callBack.LoadingCallback
import com.kingja.loadsir.core.LoadSir

class MainActivity : AppCompatActivity() {

    val loadService by lazy {
        LoadSir.getDefault().register(this, { v ->
            initData()
        })
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

//        initData()
    }

    fun initData() {
        loadService.showCallback(LoadingCallback::class.java)
        Handler().postDelayed({
            loadService.showSuccess()
        }, 2000)
    }

    fun loading(v: View) {
        loadService.showCallback(LoadingCallback::class.java)
    }

    fun error(v: View) {
        loadService.showCallback(ErrorCallback::class.java)
    }

    fun empty(v: View) {
        loadService.showCallback(EmptyCallback::class.java)
    }
}
